// pages/my/my-integral.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {

    navList: [{
        id: 0,
        name: '全部'
      },
      {
        id: 1,
        name: '未兑换'
      },
      {
        id: 2,
        name: '已兑换'
      },
    ],

    navNum: 0

  },

  bindNav(e) {
    const that = this;
    var index = e.currentTarget.dataset.index;
    this.setData({
      navNum: index
    })
    that.getIntallOrders()
  },

  bindAddress(e) {
    var that = this;
    wx.openLocation({
      latitude: parseFloat(e.currentTarget.dataset.lat),
      longitude: parseFloat(e.currentTarget.dataset.lng),
      address: e.currentTarget.dataset.address,
    })
  },

  getIntallOrders(e) {
    const that = this;
    wx.showLoading({
      title: '玩命加载中',
      mask: true,
    })
    wx.request({
      url: app.globalData.url + 'IntallOrders',
      method: 'POST',
      data: {
        uid: app.globalData.uid,
        type: that.data.navNum,
      },
      success: function (res) {
        if (res.data.info) {
          that.setData({
            orders: res.data.info.orders,
          })
        }
        wx.hideLoading()
      },
    })
  },

  navTo(e) {
    wx.navigateTo({
      url: e.currentTarget.dataset.url,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const that = this;
    that.setData({
      navNum: options.navId
    })
    that.getIntallOrders();
    wx.stopPullDownRefresh();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.onLoad();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})